/**
 * @author Mihai Moraru
 */
public class ArduinoAnalogPin extends ArduinoPin {
	public ArduinoAnalogPin(double x, double y)
	{
		super(x, y);
	}

	public int analogRead()
	{
		if(mode != ArduinoCore.INPUT)
			return 0;
		if(voltage >= ArduinoCore.reference)
			return 1023;
		if(voltage < ArduinoCore.V_LOW)
			return 0;
		return (int)((voltage-ArduinoCore.V_LOW)/(ArduinoCore.reference-ArduinoCore.V_LOW)*1024);
	}
}
